package com.zhw.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zhw.mapper.BookMapper;
import com.zhw.pojo.Book;
import com.zhw.pojo.BookDTO;
import com.zhw.pojo.PageBean;
import com.zhw.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    BookMapper bookMapper;



    @Override
    public PageBean page(BookDTO bookDTO) {
        PageHelper.startPage(bookDTO.getPage(),bookDTO.getPageSize());
        Page<Book> page=bookMapper.page(bookDTO);
        return new PageBean(page.getTotal(),page.getResult());

    }

    @Override
    public Book getByID(String isbn) {
        return bookMapper.getByID(isbn);
    }



    @Override
    public void save(Book book) {
        bookMapper.save(book);
    }

    @Override
    public void update(Book book) {
        bookMapper.update(book);
    }

    @Override
    public void delete(String isbn) {
        bookMapper.delete(isbn);
    }
}
